package com.broadsoft.cluster.smartcluster.test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.broadsoft.cluster.smartcluster.ClusterManager;
import com.broadsoft.cluster.smartcluster.message.RunTaskMessage;

/**
 * 
* FIXME: <A few lines of description of what class is about and what it does.> 
*
* <HR/><B>Modification Block</B>
* <P>
* Version: FIXME: 1.0.1 <BR>
* Author: FIXME: luzhen
* Date: 2011-9-21
* TAG: <A short name to find out all changed made by this modification.>
* Comments: Created.
* Bug fix NO.: <If required>
* </P>
* <P>
* ... Other Modifications following above structure.
* </P>
*
 */
public class ClusterExample {
    

    private static final ExecutorService thread_pool = Executors.newCachedThreadPool();
    /**
     * 
     * FIXME: <A brief description of what the method does.> 
     * FIXME: Algorithm: <MUST exist if the method is more than 10 lines. Remove if it is simple.>
     * <An Algorithm in pure English, describing the logic used in the implementation. 
     * This should not contain to any Syntax of Java, in fact, it should be language independent, 
     * and should be targeted to any new comer in the maintenance of the code.>
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        ClusterManager partitionService = new ClusterManager();
        ClusterManager partitionService2 = new ClusterManager();
        ClusterManager partitionService3 = new ClusterManager();
        partitionService.start();
        partitionService2.start();
        partitionService3.start();
        thread_pool.execute(new ExecutionRunnable(partitionService,1));
        thread_pool.execute(new ExecutionRunnable(partitionService2,1));
        thread_pool.execute(new ExecutionRunnable(partitionService3,2));

        Thread.sleep(100);
        partitionService.stop();
        //
        Thread.sleep(10000000);
        partitionService2.stop();
        partitionService3.stop();
    }// end of main

}


class ExecutionRunnable implements Runnable {
    private ClusterManager clusterManager;
    private int partitionID;

    public ExecutionRunnable(ClusterManager clusterManager,int partitionID) {
        this.clusterManager = clusterManager;
        this.partitionID=partitionID;
    }

    public void run() {
        try {
            RunTaskMessage executionTaskMessage = new RunTaskMessage(); 
//            clusterManager.invoke(executionTaskMessage, partitionID);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
    }

}